<script setup>
import { inject, onMounted, reactive, ref, watch } from 'vue'
import { useRouter } from 'vue-router';
import 'viewerjs/dist/viewer.min.css'
import 'viewerjs/dist/viewer.min.js'
import Header from '@/components/Header.vue'
import LogoMin from '@/components/svg/logo-min.vue'
import {ArrowRightBold} from "@element-plus/icons-vue";
import MpcLogoMin from "@/components/svg/mpc-logo-min.vue";

let isVerticalScreen = inject("isVerticalScreen");

function backGround() {
  var r = Math.floor(Math.random() * 360);
  var g = Math.floor(Math.random() * 360);
  // return `linear-gradient(to left bottom, hsl(${r}, 50%, 20%) 0%, hsl(${g}, 50%, 20%) 100%)`;
  return `rgb(20,20,25)`;
}
function backGrounds(){
  var r = Math.floor(Math.random()*256);
  var g = Math.floor(Math.random()*256);
  // return `linear-gradient(to left bottom,hsl(${r},100%,85%) 0%,hsl(${g},100%,85%) 100%)`;
  return `rgb(251,251,255)`;
}

const router = useRouter();
function goNav() {
  router.push('/nav');
}

let isBlackMode = inject('isBlackMode');
watch(() => isBlackMode.value, (newValue) => {
  if(isBlackMode.value) {
    document.body.style.background = backGround();
    document.body.style.color = '#fff';
  } else {
    document.body.style.color = '#213547';
    document.body.style.background = backGrounds();
  }
});

onMounted(()=>{
  if(isBlackMode.value) {
    document.body.style.background = backGround();
    document.body.style.color = '#fff';
  } else {
    document.body.style.color = '#213547';
    document.body.style.background = backGrounds();
  }
});

</script>
<template>
  <Header :is-home="true"></Header>
  <!-- 1 -->
  <div class="main-container" :class="{ 'vertical': isVerticalScreen }">
    <div :class="['card-container', isVerticalScreen ? 'vertical' : '']">
      <div class="brand_card">
        <mpc-logo-min style="width: auto; height: 50px; margin: 50px 0"></mpc-logo-min>
        <div style="height: 60px; font-size: 25px; line-height: 60px;">消息增强器核心</div>
        <div style="margin: 10px 0">消息增强器核心（message-plus-core）基于Netty网络框架创造的高性能通讯框架，提供基础的路径请求、语音请求等基础请求类型，同时支持强大的注解式自定义请求类和自定义请求处理器；并且框架自带群组及聊天室功能，使用提供的工具类即可快速调用。该框架不提供过多的实际功能，但是提供更多的接口定义，保证开发者可以自由开发。</div>
        <button class="jump_btn" style="margin-top: 20px" onclick="window.open('https://www.red-coral.cn/message-plus-core')">前往</button>
      </div>
      <div class="brand_card">
        <logo-min style="width: auto; height: 50px; margin: 50px 0"></logo-min>
        <div style="height: 60px; font-size: 25px; line-height: 60px;">消息增强器</div>
        <div style="margin: 10px 0">基于WebSocket的消息增强器，帮助开发者快速开发即时聊天系统。支持单发、群发、聊天室及系统功能;以及数据持久化；支持失败消息的持久化及重发功能。</div>
        <button class="jump_btn" style="margin-top: 20px" onclick="window.open('https://www.red-coral.cn/message-plus')">前往</button>
      </div>
    </div>
  </div>
  <!-- 底部栏 -->
  <div style="position: relative; overflow: hidden;">
    <div class="home_bottom_background"></div>
    <table class="home_bottom" border="0" :style="{'margin': isVerticalScreen?'0':'0 20vw', 'width': isVerticalScreen?'100vw':'60vw'}">
      <tbody>
      <tr>
        <td>
          <a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank" style="color: inherit;">陕ICP备2023014750号-1</a>
        </td>
        <td>red_coral20240606@163.com</td>
      </tr>
      </tbody>
    </table>
  </div>
</template>
<style scoped>
:root {
  --rc-font-family: "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

p {
  font-size: 24px;
}
/*
button {
  width: 300px;
  height: 50px;
  font-size: 24px;
  line-height: 0;
  background-color: rgb(146, 84, 222);
  color: #fff;
  transition: all 0.2s ease-in-out;
  z-index: 10;
}
button:hover{
  filter: drop-shadow(0 0 1em #646cffaa);
  color: rgba(255,255,255,1);
}
*/
.logo {
  height: 8em;
  padding: 1.5em;
  will-change: filter;
  transition: filter 300ms;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}


.home1 {
  width: 70vw;
  margin: 80px 15vw 0 15vw;
}

.logo_min_background {
  position: absolute;
  left: 10px; top: 25px;
  width: 280px; height: 250px;
  background-image: linear-gradient( -45deg, #bd34fe 50%, #47caff 50% );
  filter: blur(68px);
  transform: scale(1.4);
}

.home_btn {
  display: inline-flex;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  background-color: rgb(120,230,140);
  font-size: 15px;
  height: 40px;
  width: 110px;
  line-height: 100%;
  padding: 0 0 0 5px;
  border-radius: 15px;
  color: inherit;
  box-shadow: -1px -1px 2px 1px rgba(140,220,150,0.5), 1px 1px 2px 1px rgba(120,200,130,1);
  border: 0;
  transition: 0.2s ease-in-out;
}
.home_btn span {
  width: 60px;
  transition: 0.2s ease-in-out;
  color: inherit;
  line-height: 40px;
  height: 40px;
}
.home_btn svg {
  width: 17px;
  height: 40px;
  padding-left: 3px;
  transition: 0.2s ease-in-out;
  transform: scale(1.4);
}

.home_btn:hover {
  box-shadow: -1px -1px 2px 1px rgba(120,200,130,1), 1px 1px 2px 1px rgba(140,220,150,0.5);
}
.home_btn:hover span {
  width: 100px;
}
.home_btn:hover svg {
  width: 0;
}


.home_bottom_background {
  position: absolute;
  bottom: -50vw;
  left: 10vw;
  width: 80vw;
  height: 50vw;
  box-shadow: 0 0 100px 50px rgba(120,240,200, 0.5);
  z-index: 0;
  border-radius: 1000px;
}


.home_bottom {
  background-color: rgba(0,0,0,0);
  border: none;
  border-collapse: collapse;
  height: 200px;
  z-index: 2;
}
.home_bottom td {
  border: none;
  font-size: 13px;
}


.main-container {
  width: 80vw;
  margin: 100px 10vw 150px 10vw;
  overflow-x: hidden;
  padding-top: 60px;  /* 添加顶部内边距，避免被标题栏遮挡 */
}

.main-container.vertical {
  width: 100%;
  margin: 60px 0;  
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.card-container {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
  width: 100%;
}

.card-container.vertical {
  flex-direction: column;
  align-items: center;
  padding: 0;
  width: 100%;
}

@media screen and (max-width: 768px) {
  .brand_card {
    width: 90%;
    max-width: 400px;
    margin: 10px auto;
    padding: 20px;
    box-sizing: border-box;
  }
  
  .card-container {
    padding: 0;
    width: 100%;
  }
}


.brand_card {
  width: calc(100% - 40px);
  max-width: 400px;
  margin: 10px auto;
  padding: 20px;
}


.brand_card {
  width: 300px;
  min-height: 500px;
  height: auto;
  margin: 10px;
  border-radius: 20px;
  background-color: rgba(150,150,158,0.08);
  padding: 25px;
  transition: all 0.3s ease;
  position: relative;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

@media screen and (max-width: 768px) {
  .brand_card {
    width: calc(100% - 40px);
    max-width: 400px;
    margin: 10px 20px;
    padding: 20px;
  }
  
  .card-container {
    padding: 0 15px;
  }
}

.brand_card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.25);
  background-color: rgba(150,150,158,0.12);
}

.jump_btn {
  padding: 10px 25px;
  border-radius: 12px;
  background: linear-gradient(145deg, #6366f1, #8b5cf6);
  color: white;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.jump_btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}
</style>
